package com.froggyware.tadpole.user;

import java.util.ArrayList;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: mst
 * Date: Sep 17, 2011
 * Time: 11:26:08 PM
 * To change this template use File | Settings | File Templates.
 */
public class UserObjectMother {

    private static long startingTimestamp = 1L;

    public static User createUser(String email) {
        User u = new User();
        u.setEmail(email);
        u.setFirstName(email.substring(0, email.indexOf(".")));
        u.setLastName(email.substring(email.indexOf(".")+1, email.indexOf("@")));
        addPosts(u);
        return u;
    }

    public static void addPosts(User u) {
        u.setPosts(new ArrayList<Post>());
        u.getPosts().add(createPost("Hello World!", 0));
        u.getPosts().add(createPost("Here we try to have a simple object model.", 0));
        u.getPosts().add(createPost("We need that for developing the query interface.", 0));
        u.getPosts().add(createPost("Its much easier to design if we use a simple test.", 0));
        u.getPosts().add(createPost("Lets see how it turns out.", 0));
    }

    public static Post createPost(String comment, long timeOffset) {
        Post post = new Post();
        post.setDate(new Date(startingTimestamp + timeOffset));
        return post;
    }
    
}
